package com.example.hezhe_service_provider.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.example.hezhe_common.pojo.User;
import com.example.hezhe_interface.service.UserService;
import com.example.hezhe_service_provider.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service(interfaceClass = UserService.class)
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    //根据用户信息
    public User findByUsername(String username) {

        //查询用户的信息
        User user = userMapper.findByUsername(username);
        if (user == null){
            return null;
        }
        return user;
    }

    @Override
    public void add(User user) {
        userMapper.add(user);
    }

    @Override
    public void changeHead(String fileName,String username) {
        userMapper.changeHead(fileName,username);
    }

    @Override
    public void changePsd(String username, String newEncode) {
        userMapper.changePsd(username,newEncode);
    }

    @Override
    public void forgetPsd(String telephone, String newEncode) {
        userMapper.forgetPsd(telephone,newEncode);
    }

    @Override
    public User findByTelephone(String telephone) {
        return userMapper.findByTelephone(telephone);
    }
}
